#pragma once

typedef enum
{
	video_codec_id_h264 = 0,
	video_codec_id_h265,
	video_codec_id_mpeg4
}video_codec_id;

typedef enum
{
 audio_codec_id_aac = 0,
 audio_codec_id_g711a,
}audio_codec_id;

typedef enum
{
	container_format_mp4,
}container_format_id;

void imimp4_init_ffmpeg();

int imimp4_create_file(const char* path,
					   container_format_id container,
					   video_codec_id video,
					   audio_codec_id audio,
					   unsigned int vfps,
					   unsigned int vwidth,
					   unsigned int vheight,
					   unsigned int achannel,
					   unsigned int asamplerate,
					   /*out*/void** handle);

int imimp4_write_video_frame(void* handle,
							 unsigned char* data,
							 unsigned int data_len,
							 unsigned int vtimestamp,
							 bool iskeyframe);

int imimp4_write_audio_frame(void* handle,
							 unsigned char* data,
							 unsigned int data_len,
							 unsigned int atimestamp);

int imimp4_close_file_for_create(void* handle);

int imimp4_open_file(const char* path,
					 container_format_id* container,
					 video_codec_id* video,
					 audio_codec_id* audio,
					 unsigned int* vfps,
					 unsigned int* vwidth,
					 unsigned int* vheight,
					 unsigned int* achannel,
					 unsigned int* asamplerate,
					 unsigned int* abitrate,
					 /*out*/void** handle);

int imimp4_get_video_frame(void* handle,
						   unsigned char* data,
						   unsigned int* data_len,
						   unsigned int* timestamp,
						   bool* iskeyframe,
						   bool* isaudioframe);

int imimp4_close_file_for_open(void* handle);